package com.service.profile.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.dao.profile.ProfileDao;
import com.entity.other.Academy;
import com.entity.other.City;
import com.entity.other.Domitory;
import com.entity.other.Identify;
import com.entity.other.Industry;
import com.entity.other.IndustryBranch;
import com.entity.other.Junior;
import com.entity.other.Position;
import com.entity.other.PositionBranch;
import com.entity.other.Province;
import com.entity.other.Senior;
import com.entity.other.TechnicalSchool;
import com.entity.other.University;
import com.entity.userInfo.BasicInfo;
import com.entity.userInfo.ContactInfo;
import com.entity.userInfo.JuniorInfo;
import com.entity.userInfo.PersonalInfo;
import com.entity.userInfo.PrimaryInfo;
import com.entity.userInfo.SeniorInfo;
import com.entity.userInfo.TechnicalSchoolInfo;
import com.entity.userInfo.UniversityInfo;
import com.entity.userInfo.WorkInfo;
import com.service.profile.ProfileService;
import com.util.dao.BasicDao;

@Service("profileService")
public class ProfileServiceImpl implements ProfileService{
	
	@Autowired
	private BasicDao basicDao;
	
	@Autowired
	private ProfileDao profileDao;

	public List<Province> getAllProvince() throws Exception {
		return (List<Province>)basicDao.queryByExampleEntity(Province.class, new Province(), 0, 1000);
	}

	public List<City> getCityByProvinceId(int provinceId) throws Exception {
		return profileDao.getCityByProvinceId(provinceId);
	}

	public List<University> getUniversityByProvinceId(int provinceId)
			throws Exception {
		return profileDao.getUniversityByProvinceId(provinceId);
	}

	public List<BasicInfo> getBasicInfoByUserId(int userId) throws Exception {
		return profileDao.getBasicInfoByUserId(userId);
	}

	public List<JuniorInfo> getJuniorByUserId(int userId) throws Exception {
		return profileDao.getJuniorByUserId(userId);
	}

	public List<PersonalInfo> getPersonalInfoByUserId(int userId) throws Exception {
		return profileDao.getPersonalInfoByUserId(userId);
	}

	public List<PrimaryInfo> getPrimaryInfoByUserId(int userId)
			throws Exception {
		return profileDao.getPrimaryInfoByUserId(userId);
	}

	public List<SeniorInfo> getSeniorByUserId(int userId) throws Exception {
		return profileDao.getSeniorByUserId(userId);
	}

	public List<TechnicalSchoolInfo> getTechnicalSchoolInfoByUserId(int userId)
			throws Exception {
		return profileDao.getTechnicalSchoolInfoByUserId(userId);
	}

	public List<UniversityInfo> getUniversityByUserId(int userId) throws Exception {
		return profileDao.getUniversityByUserId(userId);
	}

	public List<University> getAllUniversity() throws Exception {
		return (List<University>)basicDao.queryByExampleEntity(University.class, new University(), 0, 10000);
	}

	public List<Academy> getAllAcademy() throws Exception {
		return (List<Academy>)basicDao.queryByExampleEntity(Academy.class, new Academy(), 0, 100000);
	}

	public List<Senior> getAllSenior() throws Exception {
		return (List<Senior>)basicDao.queryByExampleEntity(Senior.class, new Senior(), 0, 100000);
	}

	public List<TechnicalSchool> getAllTechnicalSchool() throws Exception {
		return (List<TechnicalSchool>)basicDao.queryByExampleEntity(TechnicalSchool.class, new TechnicalSchool(), 0, 100000);
	}

	public List<Junior> getAllJunior() throws Exception {
		return (List<Junior>)basicDao.queryByExampleEntity(Junior.class, new Junior(), 0, 100000);
	}

	public List<Industry> getAllIndustry() throws Exception {
		return (List<Industry>)basicDao.queryByExampleEntity(Industry.class, new Industry(), 0, 100000);
	}

	public List<IndustryBranch> getAllIndustryBranch() throws Exception {
		return (List<IndustryBranch>)basicDao.queryByExampleEntity(IndustryBranch.class, new IndustryBranch(), 0, 100000);
	}

	public List<Position> getAllPosition() throws Exception {
		return (List<Position>)basicDao.queryByExampleEntity(Position.class, new Position(), 0, 100000);
	}

	public List<PositionBranch> getAllPositionBranch() throws Exception {
		return (List<PositionBranch>)basicDao.queryByExampleEntity(PositionBranch.class, new PositionBranch(), 0, 100000);
	}

	public List<WorkInfo> getWorkInfoByUserId(int userId) throws Exception {
		return profileDao.getWorkInfoByUserId(userId);
	}

	public List<ContactInfo> getContactInfoByUserId(int userId)
			throws Exception {
		return profileDao.getContactInfoByUserId(userId);
	}

	public void updateBasicInfo(BasicInfo basicInfo) throws Exception {
		basicDao.update(basicInfo);
	}

	public List<Identify> getAllIdentify() throws Exception {
		return (List<Identify>)basicDao.queryByExampleEntity(Identify.class, new Identify(), 0, 10);
	}

	public List<Domitory> getDomitoryByUniversityId(int universityId)
			throws Exception {
		return profileDao.getDomitoryByUniversityId(universityId);
	}

	public List<Academy> getAcademyByUniversityId(int university)
			throws Exception {
		return profileDao.getAcademyByUniversityId(university);
	}

	public void saveUniversityInfo(UniversityInfo universityInfo)
			throws Exception {
		basicDao.saveOrUpdate(universityInfo);
	}

	public void delUniversityById(int universityId) throws Exception {
		UniversityInfo universityInfo=basicDao.queryById(UniversityInfo.class, universityId);
		basicDao.delete(universityInfo);
	}

	public List<IndustryBranch> getIndustryBranchByIndustryId(int industryId)
			throws Exception {
		return profileDao.getIndustryBranchByIndustryId(industryId);
	}

	public List<PositionBranch> getPositionBranchByPositionId(int positionId)
			throws Exception {
		return profileDao.getPositionBranchByPositionId(positionId);
	}

	public void saveWorkInfo(WorkInfo workInfo) throws Exception {
		basicDao.saveOrUpdate(workInfo);
	}

	public void delWorkInfoById(int workInfoId) throws Exception {
		basicDao.delete(basicDao.queryById(WorkInfo.class, workInfoId));
	}

	public void savePersonInfo(PersonalInfo personalInfo) throws Exception {
		basicDao.saveOrUpdate(personalInfo);
	}

	public void saveContactInfo(ContactInfo contactInfo) throws Exception {
		basicDao.saveOrUpdate(contactInfo);
	}

}
